import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'
// import User from '../views/User.vue'
import Main from '../views/Main.vue'

Vue.use(VueRouter)
// const originalPush = Router.prototype.push
// VueRouter.prototype.push = function push(location) {
//    return originalPush.call(this, location).catch(err => err)
// }
// 获取原型对象push函数
const originalPush = VueRouter.prototype.push

// 获取原型对象replace函数
const originalReplace = VueRouter.prototype.replace

// 修改原型对象中的push函数
VueRouter.prototype.push = function push(location){
return originalPush.call(this , location).catch(err=>err)
}

// 修改原型对象中的replace函数
VueRouter.prototype.replace = function replace(location){
return originalReplace.call(this , location).catch(err=>err)
}

const routes = [
    { 
      path: '/', 
      name: 'Main',
      component: Main,
      redirect: '/home',
      children: [
        // { path: '/home', component: Home },
        // { path: '/user', component: User },
        // { path: '/system', component:() => import('@/views/System')},
        // { path: '/404', component: () => import('@/views/other/404')},
        // { path: '/401', component: () => import('@/views/other/401')},

      ]

    },
    { 
      path: '/401', 
      component: () => import('@/views/other/401'),
    },
    { 
      path: '/404', 
      component: () => import('@/views/other/404'),
    },
    { 
      path: '/login', 
      name: 'login',
      component: () => import('@/views/Login'),
    },

  ]

const router = new VueRouter({
  mode: 'history',
    // 把常量routes放进来
    routes
 })
 
 // 导出router
 export default router